package Math;

public class _223_RectangleArea {
    public int computeArea(int A, int B, int C, int D, int E, int F, int G, int H) {
        int Sum = (D - B) * (C - A) + (H - F) * (G - E);
        if (E >= C || A >= G || H <= B || D <= F) {
            return Sum;
        }
        int up = Math.min(D, H);
        int down = Math.max(B, F);
        int left = Math.max(A, E);
        int right = Math.min(C, G);
        return Sum - (up - down) * (right - left);
    }
}
